OB.Emes_ActionButton = OB.Emes_ActionButton || {};

var QualityPutdata = {};
var QualityResultId = "";
var QualityView = null;
// BOM下DIY上传图片查看
OB.Emes_ActionButton.DiySeePicture = function(d, b) {
	var e = b.activeView.viewGrid;
	var a = e.getSelectedRecord();
	OB.Emes_ActionButton.MyRefresh=function(){
		b.refresh();
	}
	if (a != null) {
			// 选择纪录行
			var selectRecords = {
				"USER_NAME" : a.user$_identifier,   				//员工姓名
				"SEX" : a.sex,		//性别
			};
			QualityResultId = a.id;
			QualityPutdata = selectRecords;
			QualityView = b;

			copies = a.filePath;               //图案文件路径
			signboard = a.dataFilePath;		 //工艺数据文件路径
			
			isc.External_DiySeePicture.create().show();
	}else{
		isc.showMessage("请选择记录！");
	}
	
};

// checkbox
isc.defineClass("UsingCheckboxItem", "CheckboxItem");

isc.defineClass('External_DiySeePicture', isc.OBPopup);

isc.External_DiySeePicture.addProperties({
	width: 200,
	height: 100,
	align: "center",
	showMinimizeButton : false,
	showMaximizeButton : false,
	

	qualityResultForm : null,

	initWidget : function() {
		this.qualityResultForm = isc.DynamicForm.create({
			ID : "qualityResult",
			canEdit : true,
			width : "100%",
			height : 10,
			fields : [{
				width : "15%",
				type : 'text',
				readOnlyDisplay : "static",
				canEdit : false,
				startRow : true,
				value : QualityPutdata.USER_NAME,
				title : ' ',
				name : 'USER_NAME'
			}, {
				width : "25%",
				type : 'text',
				readOnlyDisplay : "static",
				canEdit : false,
				startRow : false,
				value : QualityPutdata.SEX,
				title : ' ',
				name : 'SEX'
			}]
		
		});
		
		
		
        this.createFileButton();
		
        
      //Add the elements into a layout   
		this.items = [ isc.VLayout.create({
			defaultLayoutAlign : "center",
			align : "center",
			width : "100%",
			layoutMargin : 15,
			membersMargin : 20,
			members : [
					isc.HLayout
							.create({
								defaultLayoutAlign : "center",
								align : "right",
								width : "100%",
								height : "80%",
								members : [ this.qualityResultForm ]
							}),
					isc.HLayout
							.create({
								defaultLayoutAlign : "center",
								align : "center",
								membersMargin : 10,
								marginBottom : 10,
								members : [
										this.idCardPicture,
										this.EmployeelogoPicture]
							}) ]
		}) ];

		this.Super('initWidget', arguments);
	},
	createFileButton: function() {
		var _self = this;
		this.idCardPicture = isc.OBFormButton.create({
			ID:'idCardPicture',
			title : '矢量图',
			action : function() {
				
			    var  IDcopies = copies;               //身份证
				
				if(IDcopies){
					
				   _self.showFileWin(IDcopies);
				}else{
					top.isc.showMessage("该DIY未上传矢量图。",top.isc.OBMessageBar.TYPE_SUCCESS);
				}
			}
		});
		OB.Emes_ActionButton.MyRefresh=function(){
			b.refresh();
		}
		this.EmployeelogoPicture = isc.OBFormButton.create({
			ID:'EmployeelogoPicture',
			title : '工艺文件',
			action : function() {
				
				var  newsignboard = signboard;		 //新员工标识牌
				
				if(newsignboard){
              	_self.showFileWin(newsignboard);
				}else{
					top.isc.showMessage("该DIY未上传工艺文件",top.isc.OBMessageBar.TYPE_SUCCESS);
				}
			}
		});

		
		//查看文件窗口
		this.showFileWin = function(filePath) {
			var fileName =  filePath.substring(filePath.lastIndexOf("\\") + 1);
			isc.EMES_Window_View.create({
				url: "DownFileServlet.html?path=" + encodeURIComponent(filePath) 
					+ "&online=true&fileName=" + encodeURIComponent(fileName)
			}).show();
		};
		
		this.Super('initWidget', arguments);
	},

}); 